﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.IO;

/// <summary>
///eGoldFunction 的摘要说明
/// </summary>
public class eGoldFunction
{
	public eGoldFunction()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    public string IsFile(string strPath)
    {
        string strFilePath = ConfigurationManager.AppSettings["eGold_filepath"];
        string strDate = System.DateTime.Now.Date.ToString("yyyyMMdd");
        //"E://公司项目//[CMS]//CMS//CMS//gold//dataimg/"
        //string Path1 = strFilePath + strDate + "/css/main.css";
        string Path1 = strPath + "/css/main.css";
        string Path2 = strPath;
        if (!System.IO.File.Exists(Path1))
        {
            DirectoryInfo d = Directory.CreateDirectory(Path2);
            string from = strFilePath + "/template";
            CopyFolder(from, Path2);
            //File.Copy(from + "\\left.html", strFilePath + "\\" + strDate + "\\left.html", true);
            //File.Copy(from + "\\main.html", strFilePath + "\\" + strDate + "\\main.html", true);
        }
        return "1";
    }

    private static void CopyFolder(string from, string to)
    {
        if (!Directory.Exists(to))
            Directory.CreateDirectory(to);

        // 子文件夹
        foreach (string sub in Directory.GetDirectories(from))
            CopyFolder(sub + "\\", to + "\\" + Path.GetFileName(sub) + "\\");
        // 文件
        foreach (string file in Directory.GetFiles(from))
            File.Copy(file, to + "\\" + Path.GetFileName(file), true);
    }

    public string IsEPioneerFile(string strPath)
    {
        string strFilePath = ConfigurationManager.AppSettings["eGold_filepath"];
        string strDate = System.DateTime.Now.Date.ToString("yyyyMMdd");
        string Path1 = strPath + "/css/main.css";
        string Path2 = strPath;
        if (!System.IO.File.Exists(Path1))
        {
            DirectoryInfo d = Directory.CreateDirectory(Path2);
            string from = strFilePath + "/template";
            CopyFolder(from, Path2);
        }
        return "1";
    }


  
}